/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufpe.cin.dsoa.visualvm.domain;

import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

/**
 *
 * @author rafael.lima
 */
public class QoSCharacteristic {
    
    public static final int APPLIES_TO_SERVICE = 2;
    public static final int APPLIES_TO_OPERATION = 3;
    
    private String name;
    private String appliesTo;
    private Collection<QosDimension> dimensions;

    public QoSCharacteristic(String name, String appliance) {
        this.name = name;
        this.appliesTo = appliance;
        this.dimensions = new Vector<QosDimension>();
                
    }
    
        public QoSCharacteristic(String name, String appliance, Collection<QosDimension> dim) {
        this.name = name;
        this.appliesTo = appliance;
        this.dimensions = dim;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public Collection<QosDimension> getDimensions() {
    
    	return this.dimensions;
    }
    
    public void setDimensions(Collection<QosDimension> q){
    	this.dimensions = q;
    }
    
    
    public void addDimension(QosDimension qd){
    	this.dimensions.add(qd);
    }
    
    public void removeDimension(QosDimension qd){
    	this.dimensions.remove(qd);
    }
    
    public String getID(){
    	return this.getName();
    }
    
    public String getApplicability(){
    	return this.appliesTo;
    }
    
    @Override
    public String toString(){
        return this.name;
    }
    
    @Override
    public boolean equals(Object o){
    	
    	boolean ret = false;
    	
    	ret = o != null && o instanceof QoSCharacteristic && ((QoSCharacteristic)o).getName().equals(this.getName());
    	
    	return ret;
    }

    public QosDimension getQoSDimension(String toString) {
       QosDimension ret = null;
        boolean stop = false;
        Iterator<QosDimension> it = this.dimensions.iterator();
       
        
        while(!stop && it.hasNext()){
            ret = it.next();
            stop = ret.getID().equals(toString);
            
        }
           return ret; 
        
    }

    
    
}
